package com.dynamixsoftware.printershare;

import java.lang.reflect.Array;

class AES
{
  public static final int BLOCK_SIZE = 16;
  public static final int COL_SIZE = 4;
  public static final int KEY_LENGTH = 32;
  public static final int NUM_COLS = 4;
  public static final int ROOT = 283;
  public static final int ROUNDS = 14;
  static final byte[] S = { 99, 124, 119, 123, -14, 107, 111, -59, 48, 1, 103, 43, -2, -41, -85, 118, -54, -126, -55, 125, -6, 89, 71, -16, -83, -44, -94, -81, -100, -92, 114, -64, -73, -3, -109, 38, 54, 63, -9, -52, 52, -91, -27, -15, 113, -40, 49, 21, 4, -57, 35, -61, 24, -106, 5, -102, 7, 18, -128, -30, -21, 39, -78, 117, 9, -125, 44, 26, 27, 110, 90, -96, 82, 59, -42, -77, 41, -29, 47, -124, 83, -47, 0, -19, 32, -4, -79, 91, 106, -53, -66, 57, 74, 76, 88, -49, -48, -17, -86, -5, 67, 77, 51, -123, 69, -7, 2, 127, 80, 60, -97, -88, 81, -93, 64, -113, -110, -99, 56, -11, -68, -74, -38, 33, 16, -1, -13, -46, -51, 12, 19, -20, 95, -105, 68, 23, -60, -89, 126, 61, 100, 93, 25, 115, 96, -127, 79, -36, 34, 42, -112, -120, 70, -18, -72, 20, -34, 94, 11, -37, -32, 50, 58, 10, 73, 6, 36, 92, -62, -45, -84, 98, -111, -107, -28, 121, -25, -56, 55, 109, -115, -43, 78, -87, 108, 86, -12, -22, 101, 122, -82, 8, -70, 120, 37, 46, 28, -90, -76, -58, -24, -35, 116, 31, 75, -67, -117, -118, 112, 62, -75, 102, 72, 3, -10, 14, 97, 53, 87, -71, -122, -63, 29, -98, -31, -8, -104, 17, 105, -39, -114, -108, -101, 30, -121, -23, -50, 85, 40, -33, -116, -95, -119, 13, -65, -26, 66, 104, 65, -103, 45, 15, -80, 84, -69, 22 };
  static final byte[] Si = { 82, 9, 106, -43, 48, 54, -91, 56, -65, 64, -93, -98, -127, -13, -41, -5, 124, -29, 57, -126, -101, 47, -1, -121, 52, -114, 67, 68, -60, -34, -23, -53, 84, 123, -108, 50, -90, -62, 35, 61, -18, 76, -107, 11, 66, -6, -61, 78, 8, 46, -95, 102, 40, -39, 36, -78, 118, 91, -94, 73, 109, -117, -47, 37, 114, -8, -10, 100, -122, 104, -104, 22, -44, -92, 92, -52, 93, 101, -74, -110, 108, 112, 72, 80, -3, -19, -71, -38, 94, 21, 70, 87, -89, -115, -99, -124, -112, -40, -85, 0, -116, -68, -45, 10, -9, -28, 88, 5, -72, -77, 69, 6, -48, 44, 30, -113, -54, 63, 15, 2, -63, -81, -67, 3, 1, 19, -118, 107, 58, -111, 17, 65, 79, 103, -36, -22, -105, -14, -49, -50, -16, -76, -26, 115, -106, -84, 116, 34, -25, -83, 53, -123, -30, -7, 55, -24, 28, 117, -33, 110, 71, -15, 26, 113, 29, 41, -59, -119, 111, -73, 98, 14, -86, 24, -66, 27, -4, 86, 62, 75, -58, -46, 121, 32, -102, -37, -64, -2, 120, -51, 90, -12, 31, -35, -88, 51, -120, 7, -57, 49, -79, 18, 16, 89, 39, -128, -20, 95, 96, 81, 127, -87, 25, -75, 74, 13, 45, -27, 122, -97, -109, -55, -100, -17, -96, -32, 59, 77, -82, 42, -11, -80, -56, -21, -69, 60, -125, 83, -103, 97, 23, 43, 4, 126, -70, 119, -42, 38, -31, 105, 20, 99, 85, 33, 12, 125 };
  static final int[] alog;
  static final int[] log;
  static final byte[] rcon = { 0, 1, 2, 4, 8, 16, 32, 64, -128, 27, 54, 108, -40, -85, 77, -102, 47, 94, -68, 99, -58, -105, 53, 106, -44, -77, 125, -6, -17, -59, -111 };
  static final int[] row_shift = { 0, 1, 2, 3 };
  byte[][] Kd;
  byte[][] Ke;
  int numRounds;
  
  static
  {
    alog = new int[256];
    log = new int[256];
    alog[0] = 1;
    for (int i = 1; i < 256; i++)
    {
      int k = alog[(i - 1)] << 1 ^ alog[(i - 1)];
      if ((k & 0x100) != 0) {
        k ^= 0x11B;
      }
      alog[i] = k;
    }
    for (int j = 1; j < 255; j++) {
      log[alog[j]] = j;
    }
  }
  
  public static int getRounds(int paramInt)
  {
    switch (paramInt)
    {
    default: 
      return 14;
    case 16: 
      return 10;
    }
    return 12;
  }
  
  public static void main(String[] paramArrayOfString) {}
  
  static final int mul(int paramInt1, int paramInt2)
  {
    if ((paramInt1 != 0) && (paramInt2 != 0)) {
      return alog[((log[(paramInt1 & 0xFF)] + log[(paramInt2 & 0xFF)]) % 255)];
    }
    return 0;
  }
  
  public static String static_byteArrayToString(byte[] paramArrayOfByte)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramArrayOfByte.length; i++)
    {
      int j = paramArrayOfByte[i];
      if (j < 0) {
        j += 256;
      }
      localStringBuffer.append((char)j);
    }
    return localStringBuffer.toString();
  }
  
  public static String static_intArrayToString(int[] paramArrayOfInt)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramArrayOfInt.length; i++) {
      localStringBuffer.append((char)paramArrayOfInt[i]);
    }
    return localStringBuffer.toString();
  }
  
  public static byte[] static_stringToByteArray(String paramString)
  {
    byte[] arrayOfByte = new byte[paramString.length()];
    for (int i = 0; i < paramString.length(); i++) {
      arrayOfByte[i] = ((byte)paramString.charAt(i));
    }
    return arrayOfByte;
  }
  
  public String Decrypt(String paramString)
  {
    return _cryptAll(paramString, 2);
  }
  
  public String Encrypt(String paramString)
  {
    return _cryptAll(paramString, 1);
  }
  
  public String _cryptAll(String paramString, int paramInt)
  {
    int i = paramString.length() - 16 * (paramString.length() / 16);
    int j;
    if (i > 0)
    {
      j = 1;
      if (paramInt != 1) {
        break label84;
      }
    }
    label84:
    for (int k = 1;; k = 0)
    {
      if ((k & j) == 0) {
        break label90;
      }
      for (int i2 = 0; i2 < 16 - i; i2++) {
        paramString = paramString + " ";
      }
      j = 0;
      break;
    }
    label90:
    int m = paramString.length() / 16;
    byte[] arrayOfByte1 = new byte[paramString.length()];
    new byte[16];
    for (int n = 0; n < m; n++)
    {
      byte[] arrayOfByte2 = static_stringToByteArray(paramString.substring(n * 16, 16 + n * 16));
      if (paramInt == 1) {
        arrayOfByte2 = encrypt(arrayOfByte2);
      }
      if (paramInt == 2) {
        arrayOfByte2 = decrypt(arrayOfByte2);
      }
      for (int i1 = 0; i1 < 16; i1++) {
        arrayOfByte1[(i1 + n * 16)] = arrayOfByte2[i1];
      }
    }
    return static_byteArrayToString(arrayOfByte1);
  }
  
  public byte[] decrypt(byte[] paramArrayOfByte)
  {
    byte[] arrayOfByte1 = new byte[16];
    byte[] arrayOfByte2 = new byte[16];
    if (paramArrayOfByte == null) {
      throw new IllegalArgumentException("Empty ciphertext");
    }
    if (paramArrayOfByte.length != 16) {
      throw new IllegalArgumentException("Incorrect ciphertext length");
    }
    byte[] arrayOfByte3 = this.Kd[0];
    for (int i = 0; i < 16; i++) {
      arrayOfByte1[i] = ((byte)(paramArrayOfByte[i] ^ arrayOfByte3[i]));
    }
    for (int j = 1; j < this.numRounds; j++)
    {
      byte[] arrayOfByte5 = this.Kd[j];
      for (int i2 = 0; i2 < 16; i2++)
      {
        int i7 = i2 % 4;
        arrayOfByte2[i2] = arrayOfByte1[((i2 + 16 - 4 * row_shift[i7]) % 16)];
      }
      for (int i3 = 0; i3 < 16; i3++) {
        arrayOfByte1[i3] = Si[(0xFF & arrayOfByte2[i3])];
      }
      for (int i4 = 0; i4 < 16; i4++) {
        arrayOfByte2[i4] = ((byte)(arrayOfByte1[i4] ^ arrayOfByte5[i4]));
      }
      for (int i5 = 0; i5 < 4; i5++)
      {
        int i6 = i5 * 4;
        arrayOfByte1[i6] = ((byte)(mul(14, arrayOfByte2[i6]) ^ mul(11, arrayOfByte2[(i6 + 1)]) ^ mul(13, arrayOfByte2[(i6 + 2)]) ^ mul(9, arrayOfByte2[(i6 + 3)])));
        arrayOfByte1[(i6 + 1)] = ((byte)(mul(9, arrayOfByte2[i6]) ^ mul(14, arrayOfByte2[(i6 + 1)]) ^ mul(11, arrayOfByte2[(i6 + 2)]) ^ mul(13, arrayOfByte2[(i6 + 3)])));
        arrayOfByte1[(i6 + 2)] = ((byte)(mul(13, arrayOfByte2[i6]) ^ mul(9, arrayOfByte2[(i6 + 1)]) ^ mul(14, arrayOfByte2[(i6 + 2)]) ^ mul(11, arrayOfByte2[(i6 + 3)])));
        arrayOfByte1[(i6 + 3)] = ((byte)(mul(11, arrayOfByte2[i6]) ^ mul(13, arrayOfByte2[(i6 + 1)]) ^ mul(9, arrayOfByte2[(i6 + 2)]) ^ mul(14, arrayOfByte2[(i6 + 3)])));
      }
    }
    byte[] arrayOfByte4 = this.Kd[this.numRounds];
    for (int k = 0; k < 16; k++)
    {
      int i1 = k % 4;
      arrayOfByte2[k] = arrayOfByte1[((k + 16 - 4 * row_shift[i1]) % 16)];
    }
    for (int m = 0; m < 16; m++) {
      arrayOfByte2[m] = Si[(0xFF & arrayOfByte2[m])];
    }
    for (int n = 0; n < 16; n++) {
      arrayOfByte1[n] = ((byte)(arrayOfByte2[n] ^ arrayOfByte4[n]));
    }
    return arrayOfByte1;
  }
  
  public byte[] encrypt(byte[] paramArrayOfByte)
  {
    byte[] arrayOfByte1 = new byte[16];
    byte[] arrayOfByte2 = new byte[16];
    if (paramArrayOfByte == null) {
      throw new IllegalArgumentException("Empty plaintext");
    }
    if (paramArrayOfByte.length != 16) {
      throw new IllegalArgumentException("Incorrect plaintext length");
    }
    byte[] arrayOfByte3 = this.Ke[0];
    for (int i = 0; i < 16; i++) {
      arrayOfByte1[i] = ((byte)(paramArrayOfByte[i] ^ arrayOfByte3[i]));
    }
    for (int j = 1; j < this.numRounds; j++)
    {
      byte[] arrayOfByte5 = this.Ke[j];
      for (int i2 = 0; i2 < 16; i2++) {
        arrayOfByte2[i2] = S[(0xFF & arrayOfByte1[i2])];
      }
      for (int i3 = 0; i3 < 16; i3++)
      {
        int i7 = i3 % 4;
        arrayOfByte1[i3] = arrayOfByte2[((i3 + 4 * row_shift[i7]) % 16)];
      }
      for (int i4 = 0; i4 < 4; i4++)
      {
        int i6 = i4 * 4;
        arrayOfByte2[i6] = ((byte)(mul(2, arrayOfByte1[i6]) ^ mul(3, arrayOfByte1[(i6 + 1)]) ^ arrayOfByte1[(i6 + 2)] ^ arrayOfByte1[(i6 + 3)]));
        arrayOfByte2[(i6 + 1)] = ((byte)(arrayOfByte1[i6] ^ mul(2, arrayOfByte1[(i6 + 1)]) ^ mul(3, arrayOfByte1[(i6 + 2)]) ^ arrayOfByte1[(i6 + 3)]));
        arrayOfByte2[(i6 + 2)] = ((byte)(arrayOfByte1[i6] ^ arrayOfByte1[(i6 + 1)] ^ mul(2, arrayOfByte1[(i6 + 2)]) ^ mul(3, arrayOfByte1[(i6 + 3)])));
        arrayOfByte2[(i6 + 3)] = ((byte)(mul(3, arrayOfByte1[i6]) ^ arrayOfByte1[(i6 + 1)] ^ arrayOfByte1[(i6 + 2)] ^ mul(2, arrayOfByte1[(i6 + 3)])));
      }
      for (int i5 = 0; i5 < 16; i5++) {
        arrayOfByte1[i5] = ((byte)(arrayOfByte2[i5] ^ arrayOfByte5[i5]));
      }
    }
    byte[] arrayOfByte4 = this.Ke[this.numRounds];
    for (int k = 0; k < 16; k++) {
      arrayOfByte1[k] = S[(0xFF & arrayOfByte1[k])];
    }
    for (int m = 0; m < 16; m++)
    {
      int i1 = m % 4;
      arrayOfByte2[m] = arrayOfByte1[((m + 4 * row_shift[i1]) % 16)];
    }
    for (int n = 0; n < 16; n++) {
      arrayOfByte1[n] = ((byte)(arrayOfByte2[n] ^ arrayOfByte4[n]));
    }
    return arrayOfByte1;
  }
  
  public void setKey(String paramString)
  {
    setKey(static_stringToByteArray(paramString));
  }
  
  public void setKey(byte[] paramArrayOfByte)
  {
    if (paramArrayOfByte == null) {
      throw new IllegalArgumentException("Empty key");
    }
    if ((paramArrayOfByte.length != 16) && (paramArrayOfByte.length != 24) && (paramArrayOfByte.length != 32)) {
      throw new IllegalArgumentException("Incorrect key length");
    }
    int i = paramArrayOfByte.length;
    int j = i / 4;
    this.numRounds = getRounds(i);
    int k = 4 * (1 + this.numRounds);
    byte[] arrayOfByte1 = new byte[k];
    byte[] arrayOfByte2 = new byte[k];
    byte[] arrayOfByte3 = new byte[k];
    byte[] arrayOfByte4 = new byte[k];
    int[] arrayOfInt1 = { 1 + this.numRounds, 16 };
    this.Ke = ((byte[][])Array.newInstance(Byte.TYPE, arrayOfInt1));
    int[] arrayOfInt2 = { 1 + this.numRounds, 16 };
    this.Kd = ((byte[][])Array.newInstance(Byte.TYPE, arrayOfInt2));
    int m = 0;
    int n = 0;
    while (m < j)
    {
      int i10 = n + 1;
      arrayOfByte1[m] = paramArrayOfByte[n];
      int i11 = i10 + 1;
      arrayOfByte2[m] = paramArrayOfByte[i10];
      int i12 = i11 + 1;
      arrayOfByte3[m] = paramArrayOfByte[i11];
      n = i12 + 1;
      arrayOfByte4[m] = paramArrayOfByte[i12];
      m++;
    }
    int i1 = j;
    if (i1 < k)
    {
      int i5 = arrayOfByte1[(i1 - 1)];
      int i6 = arrayOfByte2[(i1 - 1)];
      int i7 = arrayOfByte3[(i1 - 1)];
      int i8 = arrayOfByte4[(i1 - 1)];
      int i9;
      if (i1 % j == 0)
      {
        i9 = i5;
        i5 = (byte)(S[(i6 & 0xFF)] ^ rcon[(i1 / j)]);
        i6 = S[(i7 & 0xFF)];
        i7 = S[(i8 & 0xFF)];
      }
      for (i8 = S[(i9 & 0xFF)];; i8 = S[(i8 & 0xFF)])
      {
        do
        {
          arrayOfByte1[i1] = ((byte)(i5 ^ arrayOfByte1[(i1 - j)]));
          arrayOfByte2[i1] = ((byte)(i6 ^ arrayOfByte2[(i1 - j)]));
          arrayOfByte3[i1] = ((byte)(i7 ^ arrayOfByte3[(i1 - j)]));
          arrayOfByte4[i1] = ((byte)(i8 ^ arrayOfByte4[(i1 - j)]));
          i1++;
          break;
        } while ((j <= 6) || (i1 % j != 4));
        i5 = S[(i5 & 0xFF)];
        i6 = S[(i6 & 0xFF)];
        i7 = S[(i7 & 0xFF)];
      }
    }
    int i2 = 0;
    int i3 = 0;
    while (i2 < 1 + this.numRounds)
    {
      for (int i4 = 0; i4 < 4; i4++)
      {
        this.Ke[i2][(i4 * 4)] = arrayOfByte1[i3];
        this.Ke[i2][(1 + i4 * 4)] = arrayOfByte2[i3];
        this.Ke[i2][(2 + i4 * 4)] = arrayOfByte3[i3];
        this.Ke[i2][(3 + i4 * 4)] = arrayOfByte4[i3];
        this.Kd[(this.numRounds - i2)][(i4 * 4)] = arrayOfByte1[i3];
        this.Kd[(this.numRounds - i2)][(1 + i4 * 4)] = arrayOfByte2[i3];
        this.Kd[(this.numRounds - i2)][(2 + i4 * 4)] = arrayOfByte3[i3];
        this.Kd[(this.numRounds - i2)][(3 + i4 * 4)] = arrayOfByte4[i3];
        i3++;
      }
      i2++;
    }
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.AES
 * JD-Core Version:    0.7.0.1
 */